#nullable enable

using System;
using System.Collections.Generic;
using PHMEE.Diagnosis;
using PHMEE.Entities.Diagnosis;
using Volo.Abp.Domain.Services;

namespace PHMEE.Managers.Diagnosis;

public class AlarmRecordManager : DomainService, IAlarmRecordManager
{
    public AlarmRecord Create(Guid vesselId, Guid unitId, Guid? equipId, Guid pointId, DateTime alarmTimeUtc, string[] faultCodes,
        bool isNoFault, Dictionary<AlarmFeatureValue, AlarmLevel> featureAlarmLevels)
    {
        if (alarmTimeUtc.Kind is not DateTimeKind.Utc)
        {
            alarmTimeUtc = DateTime.SpecifyKind(alarmTimeUtc, DateTimeKind.Utc);
        }
        
        return new AlarmRecord(GuidGenerator.Create(), vesselId, unitId, equipId, pointId, alarmTimeUtc, faultCodes, isNoFault, featureAlarmLevels);
    }
    
    public void SetRemark(AlarmRecord alarmRecord, string remark)
    {
        alarmRecord.Remark = remark;
    }
    
    public void SetIsAcked(AlarmRecord alarmRecord, Guid ackedById, string ackedByUserName)
    {
        alarmRecord.IsAcked = true;
        alarmRecord.AckedById = ackedById;
        alarmRecord.AckedByUserName = ackedByUserName;
    }
    
}